package studio.baka.satoripixeldungeon.actors.buffs;

import studio.baka.satoripixeldungeon.messages.Messages;
import studio.baka.satoripixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;

public class WellFed extends Buff {

    {
        type = buffType.POSITIVE;
        announced = true;
    }

    int left;

    @Override
    public boolean act() {
        left--;
        if (left < 0) {
            detach();
            return true;
        } else if (left % 18 == 0) {
            target.HP = Math.min(target.HT, target.HP + 1);
        }

        spend(TICK);
        return true;
    }

    public void reset() {
        //heals one HP every 18 turns for 450 turns
        //25 HP healed in total
        left = (int) Hunger.STARVING;
    }

    @Override
    public int icon() {
        return BuffIndicator.WELL_FED;
    }

    @Override
    public String toString() {
        return Messages.get(this, "name");
    }

    @Override
    public String desc() {
        return Messages.get(this, "desc", left + 1);
    }

    private static final String LEFT = "left";

    @Override
    public void storeInBundle(Bundle bundle) {
        super.storeInBundle(bundle);
        bundle.put(LEFT, left);
    }

    @Override
    public void restoreFromBundle(Bundle bundle) {
        super.restoreFromBundle(bundle);
        left = bundle.getInt(LEFT);
    }
}
